<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <title>社交网站 - 多样式滚动公告</title>
  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
  
  <style>
    /* 基础样式 */
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
      background-color: #f8fafc;
      padding-top: 56px;
      transition: background-color 0.3s;
    }
    
    .container {
      max-width: 540px;
      margin: 0 auto;
      padding: 0 15px;
    }
    
    /* 顶部导航 */
    .main-header {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      height: 56px;
      background-color: white;
      box-shadow: 0 2px 5px rgba(0,0,0,0.05);
      z-index: 1000;
      display: flex;
      align-items: center;
      padding: 0 15px;
    }
    
    .logo {
      font-size: 20px;
      font-weight: 700;
      color: #0d6efd;
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 8px;
    }
    
    .header-actions {
      margin-left: auto;
      display: flex;
      align-items: center;
      gap: 15px;
    }
    
    .header-btn {
      width: 36px;
      height: 36px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      background: none;
      border: none;
      color: #6c757d;
      font-size: 18px;
      cursor: pointer;
    }
    
    /* 公告容器 */
    .announcement-container {
      margin: 15px 0;
      border-radius: 8px;
      overflow: hidden;
      position: relative;
      transition: all 0.3s;
    }
    
    /* 公告内容滚动区域 */
    .announcement-scroll {
      display: flex;
      white-space: nowrap;
      animation: scroll 20s linear infinite;
      padding: 12px 0;
    }
    
    .announcement-scroll:hover {
      animation-play-state: paused;
    }
    
    .announcement-item {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 0 20px;
    }
    
    .announcement-icon {
      width: 24px;
      height: 24px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    
    .announcement-text {
      font-size: 14px;
      line-height: 1.4;
    }
    
    .announcement-link {
      color: inherit;
      text-decoration: underline;
      font-weight: 500;
    }
    
    /* 关闭按钮 */
    .close-btn {
      position: absolute;
      top: 50%;
      right: 10px;
      transform: translateY(-50%);
      width: 24px;
      height: 24px;
      border-radius: 50%;
      background: rgba(0,0,0,0.1);
      border: none;
      color: inherit;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      z-index: 10;
      font-size: 14px;
    }
    
    /* 切换控制器 */
    .switcher {
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 1001;
      background-color: white;
      border-radius: 8px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.1);
      padding: 10px;
      border: 1px solid #e9ecef;
    }
    
    .switch-label {
      font-size: 13px;
      margin-bottom: 8px;
      display: block;
      font-weight: 500;
    }
    
    .style-switch {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
    }
    
    .style-btn {
      padding: 5px 10px;
      border-radius: 4px;
      font-size: 12px;
      border: 1px solid #e9ecef;
      background: white;
      cursor: pointer;
    }
    
    .style-btn.active {
      background-color: #0d6efd;
      color: white;
      border-color: #0d6efd;
    }
    
    /* 内容区域 */
    .content {
      padding: 15px 0;
    }
    
    .card {
      background-color: white;
      border-radius: 12px;
      padding: 15px;
      margin-bottom: 15px;
      box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    }
    
    /* 动画 */
    @keyframes scroll {
      0% {
        transform: translateX(100%);
      }
      100% {
        transform: translateX(-100%);
      }
    }
    
    /* 样式1 - 系统通知 */
    .style-1 .announcement-container {
      background-color: #e7f1ff;
      color: #0d47a1;
    }
    
    .style-1 .announcement-icon {
      background-color: #0d6efd;
      color: white;
    }
    
    /* 样式2 - 活动公告 */
    .style-2 .announcement-container {
      background-color: #fff3cd;
      color: #856404;
    }
    
    .style-2 .announcement-icon {
      background-color: #ffc107;
      color: #856404;
    }
    
    /* 样式3 - 重要提醒 */
    .style-3 .announcement-container {
      background-color: #f8d7da;
      color: #721c24;
    }
    
    .style-3 .announcement-icon {
      background-color: #dc3545;
      color: white;
    }
    
    /* 样式4 - 成就通知 */
    .style-4 .announcement-container {
      background-color: #d4edda;
      color: #155724;
    }
    
    .style-4 .announcement-icon {
      background-color: #28a745;
      color: white;
    }
    
    /* 样式5 - 简约透明 */
    .style-5 .announcement-container {
      background-color: rgba(0,0,0,0.03);
      color: #212529;
      border: 1px solid #e9ecef;
    }
    
    .style-5 .announcement-icon {
      background-color: #6c757d;
      color: white;
    }
    
    /* 提示框 */
    .toast {
      position: fixed;
      top: 70px;
      left: 50%;
      transform: translateX(-50%);
      background-color: rgba(0,0,0,0.8);
      color: white;
      border-radius: 8px;
      padding: 10px 15px;
      font-size: 14px;
      z-index: 10000;
      display: none;
    }
  </style>
</head>
<body class="style-1">
  <!-- 切换控制器 -->
  <div class="switcher">
    <span class="switch-label">公告样式</span>
    <div class="style-switch">
      <button class="style-btn active" data-style="1">系统通知</button>
      <button class="style-btn" data-style="2">活动公告</button>
      <button class="style-btn" data-style="3">重要提醒</button>
      <button class="style-btn" data-style="4">成就通知</button>
      <button class="style-btn" data-style="5">简约透明</button>
    </div>
  </div>
  
  <!-- 顶部导航 -->
  <header class="main-header">
    <a href="#" class="logo">
      <i class="fa fa-connectdevelop"></i>
      <span>社交圈</span>
    </a>
    
    <div class="header-actions">
      <button class="header-btn">
        <i class="fa fa-search"></i>
      </button>
      <button class="header-btn">
        <i class="fa fa-bell-o"></i>
      </button>
    </div>
  </header>
  
  <div class="container">
    <!-- 滚动公告 - 样式1 -->
    <div class="announcement-container">
      <div class="announcement-scroll">
        <div class="announcement-item">
          <div class="announcement-icon">
            <i class="fa fa-bullhorn"></i>
          </div>
          <div class="announcement-text">
            系统将于<span class="announcement-link">今晚23:00-次日02:00</span>进行维护升级，期间可能无法正常使用，敬请谅解。
          </div>
        </div>
        <div class="announcement-item">
          <div class="announcement-icon">
            <i class="fa fa-gift"></i>
          </div>
          <div class="announcement-text">
            新用户注册即可获得<span class="announcement-link">30天高级会员</span>特权，快去邀请好友吧！
          </div>
        </div>
        <div class="announcement-item">
          <div class="announcement-icon">
            <i class="fa fa-info-circle"></i>
          </div>
          <div class="announcement-text">
            隐私政策已更新，点击<span class="announcement-link">查看详情</span>了解更多信息。
          </div>
        </div>
      </div>
      <button class="close-btn" id="closeAnnouncement">
        <i class="fa fa-times"></i>
      </button>
    </div>
    
    <!-- 内容区域 -->
    <div class="content">
      <div class="card">
        <h3>推荐关注</h3>
        <p>根据您的兴趣，为您推荐了以下用户，点击关注即可获取他们的最新动态。</p>
      </div>
      
      <div class="card">
        <h3>热门话题</h3>
        <p>#夏日旅行 #美食分享 #电影推荐 #健身打卡 #职场技巧</p>
      </div>
      
      <div class="card">
        <h3>最新活动</h3>
        <p>「城市露营派对」将于6月15日举行，点击报名参与，认识更多新朋友！</p>
      </div>
    </div>
  </div>
  
  <!-- 提示框 -->
  <div class="toast" id="toast">操作成功</div>
  
  <!-- Bootstrap JS -->
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
  
  <script>
    // 获取元素
    const styleBtns = document.querySelectorAll('.style-btn');
    const announcementContainer = document.querySelector('.announcement-container');
    const closeBtn = document.getElementById('closeAnnouncement');
    const toast = document.getElementById('toast');
    let isAnnouncementVisible = true;
    
    // 切换公告样式
    styleBtns.forEach(btn => {
      btn.addEventListener('click', function() {
        // 移除所有活跃状态
        styleBtns.forEach(b => b.classList.remove('active'));
        document.body.className = '';
        
        // 添加当前样式
        this.classList.add('active');
        const style = this.getAttribute('data-style');
        document.body.classList.add(`style-${style}`);
        
        // 如果公告被关闭了，重新显示
        if (!isAnnouncementVisible) {
          announcementContainer.style.display = 'block';
          isAnnouncementVisible = true;
        }
        
        showToast(`已切换到${this.textContent}样式`);
      });
    });
    
    // 关闭公告
    closeBtn.addEventListener('click', function() {
      announcementContainer.style.display = 'none';
      isAnnouncementVisible = false;
      showToast('已关闭公告');
    });
    
    // 点击公告链接
    document.querySelectorAll('.announcement-link').forEach(link => {
      link.addEventListener('click', function(e) {
        e.preventDefault();
        showToast(`查看${this.textContent}详情`);
      });
    });
    
    // 显示提示
    function showToast(message) {
      toast.textContent = message;
      toast.style.display = 'block';
      
      setTimeout(() => {
        toast.style.display = 'none';
      }, 2000);
    }
  </script>
</body>
</html>
